package com.egao.common.manage;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.module.system.entity.Major;
import com.egao.common.module.system.service.MajorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "基础公开接口")
@RestController
@RequestMapping("${api}")
public class BasePublicController extends BaseController {

    @Resource
    private MajorService majorService;

    @ApiOperation(value = "专业集合")
    @GetMapping("/base/public/major")
    public JsonResult major() {
        List<Major> list = majorService.list(new QueryWrapper<Major>()
                .orderByAsc("code")
                .groupBy("name")
        );
        return JsonResult.ok().setData(list);
    }
}
